package net.cloudcodex.client.character.presenter;

import net.cloudcodex.client.CloudCodexEventBus;
import net.cloudcodex.client.character.handler.TextBoxBaseKeyHandler;
import net.cloudcodex.client.character.view.CharactersNoteView;
import net.cloudcodex.client.character.view.CharactersNoteViewImpl;
import net.cloudcodex.client.character.view.CharactersView.Message;
import net.cloudcodex.shared.dto.campaign.character.CharacterNoteDTO;

import com.google.inject.Inject;
import com.mvp4g.client.annotation.Presenter;
import com.mvp4g.client.presenter.BasePresenter;

/**
 * 
 * 
 * @author ADaroussin
 */
@Presenter(view = CharactersNoteViewImpl.class, multiple = true)
public class CharactersNotesPresenter extends
		BasePresenter<CharactersNoteView, CloudCodexEventBus> {
	private final Message message;
	private CharacterNoteDTO characterNoteDTO;
	TextBoxBaseKeyHandler noteTextAreaKeyHandler;
	private Long authorID ;

	@Inject
	public CharactersNotesPresenter(Message pMessage) {
		this.message = pMessage;
	}

	@Override
	public void bind() {
		noteTextAreaKeyHandler = new TextBoxBaseKeyHandler();
		noteTextAreaKeyHandler.setEventBus(eventBus);
		this.view.getTextAreaKeyDownHandler().addKeyDownHandler(
				noteTextAreaKeyHandler);
		this.view.getTextAreaKeyUpHandler().addKeyUpHandler(
				noteTextAreaKeyHandler);

	}

	public void addCharacterNote(CharacterNoteDTO characterNoteDTO) {
		this.characterNoteDTO = characterNoteDTO;
		String content = "";
		if (characterNoteDTO != null) {
			content = characterNoteDTO.getContent();
		}
		view.addCharacterNote(content);
	
	}

	/**
	 * 
	 */
	public void initview() {
		view.initComponents();
	}

	public void addCharacterID(Long id) {
		view.addCharacterNoteID(id);
	}

	public void addCharacter(Long id, String icon, String name) {
		view.addCharacterAvatar(id, icon, name);
	}
	
	public void addAuthor(Long authorId){
		this.authorID = authorID;
	}

}